package cn.xzhang.boot.mapper;

import cn.xzhang.boot.common.pojo.PageResult;
import cn.xzhang.boot.core.mapper.BaseMapperPlus;
import cn.xzhang.boot.model.dto.carousel.CarouselPageReqDTO;
import cn.xzhang.boot.model.entity.Carousel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.Objects;

/**
 * @author XiaoZhangCode
 * @description 针对表【carousel(轮播图表)】的数据库操作Mapper
 * @author <a href="https://github.com/XiaoZhangCode">XiaoZhangCode</a>
 */
public interface CarouselMapper extends BaseMapperPlus<Carousel> {

    default PageResult<Carousel> selectPage(CarouselPageReqDTO carouselPageReqDTO) {
        return selectPage(carouselPageReqDTO, new LambdaQueryWrapper<Carousel>()
                .eq(Objects.nonNull(carouselPageReqDTO.getUrl()), Carousel::getUrl, carouselPageReqDTO.getUrl())
                .eq(Objects.nonNull(carouselPageReqDTO.getPicUrl()), Carousel::getPicUrl, carouselPageReqDTO.getPicUrl())
                .eq(Objects.nonNull(carouselPageReqDTO.getTarget()), Carousel::getTarget, carouselPageReqDTO.getTarget())
                .eq(Objects.nonNull(carouselPageReqDTO.getAppId()), Carousel::getAppId, carouselPageReqDTO.getAppId())
                .orderByDesc(Carousel::getCreateTime)

        );
    }

}




